//
//  SKPrintUtil.swift
//  SKClock
//
//  Created by YouLong on 2021/12/22.
//

import Foundation


/// 多参数要使用【"\(Value)"】的形式！
public func skprint(_ message: Any..., file: String = #file, funcName: String = #function, line: Int = #line, hasTime: Bool = false) 
{
    #if DEBUG
    
    let fileName = (file as NSString).lastPathComponent.replacingOccurrences(of: ".swift", with: "")
    var msgStr = ""
    message.forEach { (item) in
        msgStr.append("\(item) ")
    }
    
    if hasTime {
        print("\(currentLogTimeStr()), <\(fileName)>, \(funcName), [line: \(line)] \(msgStr)")
    } else {
        print("<\(fileName)>, \(funcName), [line: \(line)] \(msgStr)")
    }
    
    #endif
}


fileprivate func currentLogTimeStr() -> String {
    let fmt = DateFormatter()
    fmt.dateFormat = "HH:mm:ss.sss"
    return fmt.string(from: Date())
} 


